<?php

declare(strict_types=1);
/**
 * This file is part of MineAdmin.
 *
 * @link     https://www.mineadmin.com
 * @document https://doc.mineadmin.com
 * @contact  root@imoi.cn
 * @license  https://github.com/mineadmin/MineAdmin/blob/master/LICENSE
 */

namespace App\Http\Admin\Request\Homework;

use App\Schema\HomeworkSchema;
use Hyperf\Validation\Request\FormRequest;
use Mine\Swagger\Attributes\FormRequest as FormRequestAnnotation;

#[FormRequestAnnotation(
    schema: HomeworkSchema::class,
    title: '创建作业',
    required: [
        'title',
        'type',
        'remark',
        'mode',
        'option',
    ],
    only: [
        'title',
        'type',
        'remark',
        'mode',
        'option',
    ]
)]
class HomeworkRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'title' => 'required|string',
            'type' => 'required|string',
            'remark' => 'required|string',
            'mode' => 'required|string',
            'option' => 'required|array',
        ];
    }

    public function attributes(): array
    {
        return [
            'title' => trans('homework.title'),
            'type' => trans('homework.type'),
            'remark' => trans('homework.remark'),
            'mode' => trans('homework.mode'),
            'option' => trans('homework.option'),
        ];
    }
}
